package cn.jsu.oj.dispatchServer.satellite.handler;

import cn.jsu.oj.dispatchServer.satellite.annotation.HandlerType;
import cn.jsu.oj.dispatchServer.satellite.heart.HeartClientService;
import cn.jsu.oj.dispatchServer.satellite.netty.starter.SatelliteStarter;
import cn.jsu.oj.dispatchServer.satellite.pojo.net.PackNet;
import cn.jsu.oj.dispatchServer.satellite.util.SpringUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Objects;

/**
 * 心跳处理器
 *
 * @author shan
 * @date 2022/07/07
 */
@Slf4j
@Component("heartHandler")
@HandlerType(typeNo = 2)
public class HeartHandler implements Handler {

    @Override
    public void handle(PackNet<?> packNet) {
        SatelliteStarter.verifySign = true;
        ((HeartClientService) Objects.requireNonNull
                (SpringUtil.getBean("heartClientService")
                        , "----------心跳服务站点获取失败......"))
                .addResponse(packNet);
    }
}
